<HTML>

<HEAD>
        <META NAME="keywords" CONTENT="electronic commerce, ecommerce, ebusiness, e-business, e-commerce, enterprise software, net economy, Netscape, Sun Microsystems, Sun-Netscape Alliance, iPlanet, internet software">
        <META NAME="description" CONTENT="The Sun-Netscape Alliance, a strategic alliance formed by America Online and Sun Microsystems, Inc., is delivering iPlanet e-commerce software and enterprise solutions that enable companies to compete successfully in the Net Economy">
	<META HTTP-EQUIV="Content-Type" content="text/html; charset=ISO-8859-1">
	<META NAME="TEMPLATEBASE" CONTENT="Authored in FrameMaker. Converted to HTML in WebWorks Publisher 2000. manual wdt 1.5">
	<META NAME="LASTUPDATED" CONTENT="09/28/00 13:18:00">
	<TITLE> Core JavaScript Guide 1.5: 5 Statements</TITLE>
</HEAD>




<BODY TEXT="#000000" LINK="#666699" VLINK="#666699" ALINK="#333366" BGCOLOR="#FFFFFF">

<MAINCONTENT>

<NAVIGATIONCONTENT>
   <TABLE WIDTH="100%" BORDER="0" CELLSPACING="4">
      <TR>
         <TD VALIGN="TOP">
            <b><a href="regexp.html">
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#993300">Previous</a></FONT>&nbsp;&nbsp;&nbsp;&nbsp;</b>
<a href="contents.html">
<b><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#993300">Contents</a></FONT></b>&nbsp;&nbsp;&nbsp;&nbsp;
<a href="ix.html"><b><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#993300">Index</a></FONT></b>&nbsp;&nbsp;&nbsp;&nbsp;
<a href="fcns.html">
<b>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#993300">
Next
</a>
</FONT>
</b>&nbsp;&nbsp;&nbsp;&nbsp;
         </TD>
     </TR>

      <TR>
         <TD VALIGN="TOP" ALIGN="RIGHT" BGCOLOR="#CCCCCC">
            <FONT FACE="Arial, Helvetica, sans-serif" COLOR="#000000" SIZE="2"><B>
             Core JavaScript Guide 1.5</B></FONT>
         </TD>
      </TR>
      <TR>
   </TABLE>
   <BR>
</NAVIGATIONCONTENT>

<BOOKCONTENT>
   <blockquote>
<BR>
<BR>

      <A NAME="1008300"> </A><A NAME=""> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="4" COLOR="#666666"><B>
<zchapnumber>Chapter 5 </zchapnumber>
&nbsp;
</B>
</FONT>


<A NAME="1008303"> </A>
<A NAME="Statements"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="4" COLOR="#000000">
<B>
<zchaptitle>Statements</zchaptitle>
</B>
</FONT>
<BR>
<BR>
<BR>

<A NAME="1008305"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>JavaScript supports a compact set of statements that you can use to incorporate a great deal of interactivity in Web pages. This chapter provides an overview of these statements.</zparagraph>
</FONT>
<P>

<A NAME="1009733"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>This chapter contains the following sections, which provide a brief overview of each statement:</zparagraph>
</FONT>
<P>
<ul>
<A NAME="1016300"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1>Block Statement: { }</zsmartlist1>
</FONT>
<P><A NAME="1009737"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1><A HREF="stmtsov.html#1008319"  >Conditional Statements</A>: <FONT FACE="courier, couriernew, monospaced size">if...else</FONT> and <FONT FACE="courier, couriernew, monospaced size">switch</FONT></zsmartlist1>
</FONT>
<P><A NAME="1009798"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1><A HREF="stmtsov.html#1008340"  >Loop Statements</A>: <FONT FACE="courier, couriernew, monospaced size">for</FONT>, <FONT FACE="courier, couriernew, monospaced size">while</FONT>,<FONT FACE="courier, couriernew, monospaced size"> do while</FONT>,<FONT FACE="courier, couriernew, monospaced size"> </FONT>label, <FONT FACE="courier, couriernew, monospaced size">break</FONT>, and<FONT FACE="courier, couriernew, monospaced size"> continue</FONT> (label is not itself a looping statement, but is frequently used with these statements)</zsmartlist1>
</FONT>
<P><A NAME="1009832"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1><A HREF="stmtsov.html#1008417"  >Object Manipulation Statements</A>: <FONT FACE="courier, couriernew, monospaced size">for...in </FONT>and <FONT FACE="courier, couriernew, monospaced size">with</FONT></zsmartlist1>
</FONT>
<P><A NAME="1009837"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1><A HREF="stmtsov.html#1008468"  >Comments</A></zsmartlist1>
</FONT>
<P><A NAME="1011497"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1><A HREF="stmtsov.html#1011537"  >Exception Handling Statements</A>: <FONT FACE="courier, couriernew, monospaced size">try...catch </FONT>and <FONT FACE="courier, couriernew, monospaced size">throw</FONT></zsmartlist1>
</FONT>
<P></ul>

<A NAME="1014479"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>Any expression is also a statement. See <A HREF="expr.html#1008302"  >Chapter 3, "Expressions and Operators,"</A> for complete information about statements.</zparagraph>
</FONT>
<P>

<A NAME="1014489"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>Use the semicolon (;) character to separate statements in JavaScript code.</zparagraph>
</FONT>
<P>

<A NAME="1009782"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>See the <A HREF="http://developer.netscape.com/docs/manuals/js/core/jsref/index.htm"><I>Core JavaScript Reference</I></A> for details about the statements in this chapter.</zparagraph>
</FONT>
<P>

<BR>
<BR>

<A NAME="1016322"> </A>
<A NAME="Block Statement"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="4">
<zhead1>Block Statement</zhead1>
<HR SIZE="2" NOSHADE>
</FONT>
<BR>


<A NAME="1016334"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>A block statement is used to group statements. The block is delimited by a pair of curly brackets:</zparagraph>
</FONT>
<P>
<A NAME="1016346"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>{statement1 statement2 . . .statement<I>n</I>}
</zcodeline>
</FONT>
<P>
<BR>
<BR>

<A NAME="1008319"> </A>
<A NAME="Conditional Statements"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="4">
<zhead1>Conditional Statements</zhead1>
<HR SIZE="2" NOSHADE>
</FONT>
<BR>


<A NAME="1008320"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>A conditional statement is a set of commands that executes if a specified condition is true. JavaScript supports two conditional statements: <FONT FACE="courier, couriernew, monospaced size">if...else</FONT> and <FONT FACE="courier, couriernew, monospaced size">switch</FONT>.</zparagraph>
</FONT>
<P>
<P>
<BR>
<A NAME="1008323"> </A>
<A NAME="if...else Statement"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="4">
<zhead2>if...else Statement</zhead2>
</FONT>
<BR>
<BR>



<A NAME="1008324"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>Use the <FONT FACE="courier, couriernew, monospaced size">if</FONT> statement to perform certain statements if a logical condition is true; use the optional <FONT FACE="courier, couriernew, monospaced size">else</FONT> clause to perform other statements if the condition is false. An <FONT FACE="courier, couriernew, monospaced size">if</FONT> statement looks as follows:</zparagraph>
</FONT>
<P>
<A NAME="1008325"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>if (<I>condition</I>) {<br>
&nbsp;&nbsp;&nbsp;<I>statements1</I> <br>
}<br>
[else {<br>
&nbsp;&nbsp;&nbsp;<I>statements2</I> <br>
} ]
</zcodeline>
</FONT>
<P>
<A NAME="1008326"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The condition can be any JavaScript expression that evaluates to true or false. The statements to be executed can be any JavaScript statements, including further nested <FONT FACE="courier, couriernew, monospaced size">if</FONT> statements. If you want to use more than one statement after an <FONT FACE="courier, couriernew, monospaced size">if</FONT> or <FONT FACE="courier, couriernew, monospaced size">else</FONT> statement, you must enclose the statements in curly braces, {}.</zparagraph>
</FONT>
<P>

<A NAME="1015870"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>You should not use simple assignments in a conditional statement. For example, do not use the following code:</zparagraph>
</FONT>
<P>
<A NAME="1015871"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>if(x = y)<br>
{<br>
&nbsp;&nbsp;&nbsp;/* do the right thing */<br>
}
</zcodeline>
</FONT>
<P>
<A NAME="1015872"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>If you need to use an assignment in a conditional statement, put additional parentheses around the assignment. For example, use <FONT FACE="courier, couriernew, monospaced size">if( (x = y) )</FONT>.</zparagraph>
</FONT>
<P>

<A NAME="1015886"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>Do not confuse the primitive Boolean values true and false with the true and false values of the Boolean object. Any object whose value is not undefined, null, zero, NaN, or the empty string, including a Boolean object whose value is false, evaluates to true when passed to a conditional statement. For example:</zparagraph>
</FONT>
<P>
<A NAME="1014538"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>var b = new Boolean(false);<br>
if (b) // this condition evaluates to true
</zcodeline>
</FONT>
<P>
<A NAME="1008327"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph><B>Example.</B> In the following example, the function <FONT FACE="courier, couriernew, monospaced size">checkData</FONT> returns true if the number of characters in a <FONT FACE="courier, couriernew, monospaced size">Text</FONT> object is three; otherwise, it displays an alert and returns false.</zparagraph>
</FONT>
<P>
<A NAME="1008328"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>function checkData () {<br>
&nbsp;&nbsp;&nbsp;if (document.form1.threeChar.value.length == 3) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return true<br>
&nbsp;&nbsp;&nbsp;} else {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert("Enter exactly three characters. " + &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.form1.threeChar.value + " is not valid.")<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return false<br>
&nbsp;&nbsp;&nbsp;}<br>
}
</zcodeline>
</FONT>
<P><P>
<BR>
<A NAME="1008329"> </A>
<A NAME="switch Statement"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="4">
<zhead2>switch Statement</zhead2>
</FONT>
<BR>
<BR>



<A NAME="1008330"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>A <FONT FACE="courier, couriernew, monospaced size">switch</FONT> statement allows a program to evaluate an expression and attempt to match the expression's value to a case label. If a match is found, the program executes the associated statement. A <FONT FACE="courier, couriernew, monospaced size">switch</FONT> statement looks as follows:</zparagraph>
</FONT>
<P>
<A NAME="1008331"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>switch (<I>expression</I>){<br>
&nbsp;&nbsp;&nbsp;case <I>label</I> : <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<I>statement</I>;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br>
&nbsp;&nbsp;&nbsp;case <I>label</I> : <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<I>statement</I>;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br>
&nbsp;&nbsp;&nbsp;...<br>
&nbsp;&nbsp;&nbsp;default : <I>statement</I>;<br>
}
</zcodeline>
</FONT>
<P>
<A NAME="1008332"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The program first looks for a label matching the value of expression and then executes the associated statement. If no matching label is found, the program looks for the optional <FONT FACE="courier, couriernew, monospaced size">default</FONT> statement, and if found, executes the associated statement. If no default statement is found, the program continues execution at the statement following the end of <FONT FACE="courier, couriernew, monospaced size">switch</FONT>.</zparagraph>
</FONT>
<P>

<A NAME="1008333"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The optional <FONT FACE="courier, couriernew, monospaced size">break</FONT> statement associated with each case label ensures that the program breaks out of <FONT FACE="courier, couriernew, monospaced size">switch</FONT> once the matched statement is executed and continues execution at the statement following switch. If <FONT FACE="courier, couriernew, monospaced size">break</FONT> is omitted, the program continues execution at the next statement in the <FONT FACE="courier, couriernew, monospaced size">switch</FONT> statement.</zparagraph>
</FONT>
<P>

<A NAME="1008334"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph><B>Example.</B> In the following example, if <FONT FACE="courier, couriernew, monospaced size">expr</FONT> evaluates to "Bananas", the program matches the value with case "Bananas" and executes the associated statement. When <FONT FACE="courier, couriernew, monospaced size">break</FONT> is encountered, the program terminates <FONT FACE="courier, couriernew, monospaced size">switch</FONT> and executes the statement following <FONT FACE="courier, couriernew, monospaced size">switch</FONT>. If <FONT FACE="courier, couriernew, monospaced size">break</FONT> were omitted, the statement for case "Cherries" would also be executed.</zparagraph>
</FONT>
<P>
<A NAME="1010429"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>switch (expr) {<br>
&nbsp;&nbsp;&nbsp;case "Oranges" : <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.write("Oranges are $0.59 a pound.&lt;BR&gt;"); <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break; <br>
&nbsp;&nbsp;&nbsp;case "Apples" :<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.write("Apples are $0.32 a pound.&lt;BR&gt;");<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br>
&nbsp;&nbsp;&nbsp;case "Bananas" : <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.write("Bananas are $0.48 a pound.&lt;BR&gt;"); <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break; <br>
&nbsp;&nbsp;&nbsp;case "Cherries" :<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.write("Cherries are $3.00 a pound.&lt;BR&gt;");<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break; <br>
&nbsp;&nbsp;&nbsp;default :<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.write("Sorry, we are out of " + i + ".&lt;BR&gt;"); <br>
}
</zcodeline>
</FONT>
<P><A NAME="1008337"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>document.write("Is there anything else you'd like?&lt;BR&gt;");
</zcodeline>
</FONT>
<P>
<BR>
<BR>

<A NAME="1008340"> </A>
<A NAME="Loop Statements"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="4">
<zhead1>Loop Statements</zhead1>
<HR SIZE="2" NOSHADE>
</FONT>
<BR>


<A NAME="1008341"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>A loop is a set of commands that executes repeatedly until a specified condition is met. JavaScript supports the <FONT FACE="courier, couriernew, monospaced size">for</FONT>, <FONT FACE="courier, couriernew, monospaced size">do while</FONT>, and <FONT FACE="courier, couriernew, monospaced size">while </FONT>loop statements, as well as label (label is not itself a looping statement, but is frequently used with these statements). In addition, you can use the <FONT FACE="courier, couriernew, monospaced size">break</FONT> and <FONT FACE="courier, couriernew, monospaced size">continue</FONT> statements within loop statements.</zparagraph>
</FONT>
<P>

<A NAME="1008342"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>Another statement, <FONT FACE="courier, couriernew, monospaced size">for...in</FONT>, executes statements repeatedly but is used for object manipulation. See <A HREF="stmtsov.html#1008417"  >Object Manipulation Statements</A>.</zparagraph>
</FONT>
<P>
<P>
<BR>
<A NAME="1008347"> </A>
<A NAME="for Statement"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="4">
<zhead2>for Statement</zhead2>
</FONT>
<BR>
<BR>



<A NAME="1008349"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>A <FONT FACE="courier, couriernew, monospaced size">for</FONT> loop repeats until a specified condition evaluates to false. The JavaScript <FONT FACE="courier, couriernew, monospaced size">for</FONT> loop is similar to the Java and C <FONT FACE="courier, couriernew, monospaced size">for</FONT> loop. A <FONT FACE="courier, couriernew, monospaced size">for</FONT> statement looks as follows:</zparagraph>
</FONT>
<P>
<A NAME="1008350"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>for ([<I>initialExpression</I>]; [<I>condition</I>]; [<I>incrementExpression</I>]) {<br>
&nbsp;&nbsp;&nbsp;<I>statements<br>
</I>}
</zcodeline>
</FONT>
<P>
<A NAME="1008351"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>When a <FONT FACE="courier, couriernew, monospaced size">for</FONT> loop executes, the following occurs:</zparagraph>
</FONT>
<P>
<ol type="1">
<A NAME="1008352"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li value="1"></B>
<zsmartlist1>The initializing expression <FONT FACE="courier, couriernew, monospaced size">initial-expression</FONT>, if any, is executed. This expression usually initializes one or more loop counters, but the syntax allows an expression of any degree of complexity. This expression can also declare variables.</zsmartlist1>
</FONT>
<P><A NAME="1008353"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li value="2"></B>
<zsmartlist1>The <FONT FACE="courier, couriernew, monospaced size">condition</FONT> expression is evaluated. If the value of <FONT FACE="courier, couriernew, monospaced size">condition</FONT> is true, the loop statements execute. If the value of <FONT FACE="courier, couriernew, monospaced size">condition</FONT> is false, the <FONT FACE="courier, couriernew, monospaced size">for</FONT> loop terminates. If the <FONT FACE="courier, couriernew, monospaced size">condition</FONT> expression is omitted entirely, the condition is assumed to be true.</zsmartlist1>
</FONT>
<P><A NAME="1014494"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li value="3"></B>
<zsmartlist1>The <FONT FACE="courier, couriernew, monospaced size">statements</FONT> execute.</zsmartlist1>
</FONT>
<P><A NAME="1008354"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li value="4"></B>
<zsmartlist1>The update expression <FONT FACE="courier, couriernew, monospaced size">incrementExpression</FONT>, if there is one, executes, and control returns to <A HREF="stmtsov.html#1008353"  >Step 2</A>.</zsmartlist1>
</FONT>
<P></ol>

<A NAME="1008356"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph><B>Example.</B> The following function contains a <FONT FACE="courier, couriernew, monospaced size">for</FONT> statement that counts the number of selected options in a scrolling list (a <FONT FACE="courier, couriernew, monospaced size">Select</FONT> object that allows multiple selections). The <FONT FACE="courier, couriernew, monospaced size">for</FONT> statement declares the variable <FONT FACE="courier, couriernew, monospaced size">i</FONT> and initializes it to zero. It checks that <FONT FACE="courier, couriernew, monospaced size">i</FONT> is less than the number of options in the <FONT FACE="courier, couriernew, monospaced size">Select</FONT> object, performs the succeeding <FONT FACE="courier, couriernew, monospaced size">if</FONT> statement, and increments <FONT FACE="courier, couriernew, monospaced size">i</FONT> by one after each pass through the loop.</zparagraph>
</FONT>
<P>
<A NAME="1015800"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>&lt;SCRIPT&gt;<br>
function howMany(selectObject) {<br>
&nbsp;&nbsp;&nbsp;var numberSelected=0;<br>
&nbsp;&nbsp;&nbsp;for (var i=0; i &lt; selectObject.options.length; i++) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (selectObject.options[i].selected==true)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;numberSelected++;<br>
&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;&nbsp;return numberSelected;<br>
}
</zcodeline>
</FONT>
<P><A NAME="1015803"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>&lt;/SCRIPT&gt;<br>
&lt;FORM NAME="selectForm"&gt;<br>
&lt;P&gt;&lt;B&gt;Choose some music types, then click the button below:&lt;/B&gt;<br>
&lt;BR&gt;&lt;SELECT NAME="musicTypes" MULTIPLE&gt;<br>
&lt;OPTION SELECTED&gt; R&amp;B<br>
&lt;OPTION&gt; Jazz<br>
&lt;OPTION&gt; Blues<br>
&lt;OPTION&gt; New Age<br>
&lt;OPTION&gt; Classical<br>
&lt;OPTION&gt; Opera<br>
&lt;/SELECT&gt;<br>
&lt;P&gt;&lt;INPUT TYPE="button" VALUE="How many are selected?"<br>
onClick="alert ('Number of options selected: ' + 
howMany(document.selectForm.musicTypes))"&gt;<br>
&lt;/FORM&gt;
</zcodeline>
</FONT>
<P><P>
<BR>
<A NAME="1008359"> </A>
<A NAME="do...while Statement"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="4">
<zhead2>do...while Statement</zhead2>
</FONT>
<BR>
<BR>



<A NAME="1008360"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The <FONT FACE="courier, couriernew, monospaced size">do...while</FONT> statement repeats until a specified condition evaluates to false. A <FONT FACE="courier, couriernew, monospaced size">do...while</FONT> statement looks as follows:</zparagraph>
</FONT>
<P>
<A NAME="1008361"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>do<FONT FACE="courier, couriernew, monospaced size"> {<br>
</FONT>&nbsp;&nbsp;&nbsp;<I>statement<br>
</I>}<FONT FACE="courier, couriernew, monospaced size"> </FONT>while<FONT FACE="courier, couriernew, monospaced size"> (</FONT><I>condition</I><FONT FACE="courier, couriernew, monospaced size">)
</FONT></zcodeline>
</FONT>
<P>
<A NAME="1008362"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph><FONT FACE="courier, couriernew, monospaced size">statement</FONT> executes once before the condition is checked. If <FONT FACE="courier, couriernew, monospaced size">condition</FONT> is true, the statement executes again. At the end of every execution, the condition is checked. When the condition is false, execution stops and control passes to the statement following <FONT FACE="courier, couriernew, monospaced size">do...while</FONT>.</zparagraph>
</FONT>
<P>

<A NAME="1008363"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph><B>Example.</B> In the following example, the <FONT FACE="courier, couriernew, monospaced size">do</FONT> loop iterates at least once and reiterates until i is no longer less than 5.</zparagraph>
</FONT>
<P>
<A NAME="1008364"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>do {<br>
&nbsp;&nbsp;&nbsp;i+=1;<br>
&nbsp;&nbsp;&nbsp;document.write(i);<br>
} while (i&lt;5);
</zcodeline>
</FONT>
<P><P>
<BR>
<A NAME="1008366"> </A>
<A NAME="while Statement"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="4">
<zhead2>while Statement</zhead2>
</FONT>
<BR>
<BR>



<A NAME="1008367"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>A <FONT FACE="courier, couriernew, monospaced size">while</FONT> statement executes its statements as long as a specified condition evaluates to true. A <FONT FACE="courier, couriernew, monospaced size">while</FONT> statement looks as follows:</zparagraph>
</FONT>
<P>
<A NAME="1008368"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>while (<I>condition</I>) {<br>
&nbsp;&nbsp;&nbsp;<I>statements<br>
</I>}
</zcodeline>
</FONT>
<P>
<A NAME="1008369"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>If the condition becomes false, the statements within the loop stop executing and control passes to the statement following the loop.</zparagraph>
</FONT>
<P>

<A NAME="1008370"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The condition test occurs before the statements in the loop are executed. If the condition returns true, the statements are executed and the condition is tested again. If the condition returns false, execution stops and control is passed to the statement following <FONT FACE="courier, couriernew, monospaced size">while</FONT>.</zparagraph>
</FONT>
<P>

<A NAME="1008371"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph><B>Example 1.</B> The following <FONT FACE="courier, couriernew, monospaced size">while</FONT> loop iterates as long as <FONT FACE="courier, couriernew, monospaced size">n</FONT> is less than three:</zparagraph>
</FONT>
<P>
<A NAME="1008372"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>n = 0;<br>
x = 0;<br>
while( n &lt; 3 ) {<br>
&nbsp;&nbsp;&nbsp;n ++;<br>
&nbsp;&nbsp;&nbsp;x += n;<br>
}
</zcodeline>
</FONT>
<P>
<A NAME="1008373"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>With each iteration, the loop increments <FONT FACE="courier, couriernew, monospaced size">n</FONT> and adds that value to <FONT FACE="courier, couriernew, monospaced size">x</FONT>. Therefore, <FONT FACE="courier, couriernew, monospaced size">x</FONT> and <FONT FACE="courier, couriernew, monospaced size">n</FONT> take on the following values:</zparagraph>
</FONT>
<P>
<ul>
<A NAME="1008374"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1>After the first pass: <FONT FACE="courier, couriernew, monospaced size">n</FONT> = 1 and <FONT FACE="courier, couriernew, monospaced size">x</FONT> = 1</zsmartlist1>
</FONT>
<P><A NAME="1008375"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1>After the second pass: <FONT FACE="courier, couriernew, monospaced size">n</FONT> = 2 and <FONT FACE="courier, couriernew, monospaced size">x</FONT> = 3</zsmartlist1>
</FONT>
<P><A NAME="1008376"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1>After the third pass: <FONT FACE="courier, couriernew, monospaced size">n</FONT> = 3 and <FONT FACE="courier, couriernew, monospaced size">x</FONT> = 6</zsmartlist1>
</FONT>
<P></ul>

<A NAME="1008377"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>After completing the third pass, the condition <FONT FACE="courier, couriernew, monospaced size">n &lt; 3</FONT> is no longer true, so the loop terminates.</zparagraph>
</FONT>
<P>

<A NAME="1008378"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph><B>Example 2: infinite loop.</B> Make sure the condition in a loop eventually becomes false; otherwise, the loop will never terminate. The statements in the following <FONT FACE="courier, couriernew, monospaced size">while</FONT> loop execute forever because the condition never becomes false:</zparagraph>
</FONT>
<P>
<A NAME="1010472"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>while (true) {<br>
&nbsp;&nbsp;&nbsp;alert("Hello, world") }
</zcodeline>
</FONT>
<P><P>
<BR>
<A NAME="1010474"> </A>
<A NAME="label Statement"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="4">
<zhead2>label Statement</zhead2>
</FONT>
<BR>
<BR>



<A NAME="1008383"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>A label provides a statement with an identifier that lets you refer to it elsewhere in your program. For example, you can use a label to identify a loop, and then use the <FONT FACE="courier, couriernew, monospaced size">break</FONT> or <FONT FACE="courier, couriernew, monospaced size">continue</FONT> statements to indicate whether a program should interrupt the loop or continue its execution.</zparagraph>
</FONT>
<P>

<A NAME="1014644"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The syntax of the label statement looks like the following:</zparagraph>
</FONT>
<P>
<A NAME="1008384"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline><I>label</I> : <br>
&nbsp;&nbsp;&nbsp;<I>statement
</I></zcodeline>
</FONT>
<P>
<A NAME="1008385"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The value of <FONT FACE="courier, couriernew, monospaced size"><I>label </I></font>may be any JavaScript identifier that is not a reserved word. The <FONT FACE="courier, couriernew, monospaced size"><I>statement</I></font> that you identify with a label may be any statement.</zparagraph>
</FONT>
<P>

<A NAME="1014768"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph><B>Example.</B> In this example, the label <FONT FACE="courier, couriernew, monospaced size">markLoop</FONT> identifies a <FONT FACE="courier, couriernew, monospaced size">while</FONT> loop.</zparagraph>
</FONT>
<P>
<A NAME="1014713"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>markLoop:<br>
while (theMark == true)<br>
&nbsp;&nbsp;&nbsp;doSomething();<br>
}
</zcodeline>
</FONT>
<P><P>
<BR>
<A NAME="1008389"> </A>
<A NAME="break Statement"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="4">
<zhead2>break Statement</zhead2>
</FONT>
<BR>
<BR>



<A NAME="1008390"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>Use the <FONT FACE="courier, couriernew, monospaced size">break</FONT> statement to terminate a loop, <FONT FACE="courier, couriernew, monospaced size">switch</FONT>, or label statement.</zparagraph>
</FONT>
<P>
<ul>
<A NAME="1008391"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1>When you use <FONT FACE="courier, couriernew, monospaced size">break</FONT> without a label, it terminates the innermost enclosing <FONT FACE="courier, couriernew, monospaced size">while</FONT>, <FONT FACE="courier, couriernew, monospaced size">do-while</FONT>, <FONT FACE="courier, couriernew, monospaced size">for</FONT>, or <FONT FACE="courier, couriernew, monospaced size">switch</FONT> immediately and transfers control to the following statement.</zsmartlist1>
</FONT>
<P><A NAME="1008392"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1>When you use <FONT FACE="courier, couriernew, monospaced size">break</FONT> with a label, it terminates the specified labeled statement.</zsmartlist1>
</FONT>
<P></ul>

<A NAME="1014917"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The syntax of the <FONT FACE="courier, couriernew, monospaced size">break</FONT> statement looks like this:</zparagraph>
</FONT>
<P>
<A NAME="1008396"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>1. break<br>
2. break <I>label
</I></zcodeline>
</FONT>
<P>
<A NAME="1014993"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The first form of the syntax terminates the innermost enclosing loop or <FONT FACE="courier, couriernew, monospaced size">switch</FONT>; the second form of the syntax terminates the specified enclosing label statement.</zparagraph>
</FONT>
<P>

<A NAME="1014994"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph><B>Example.</B> The following example iterates through the elements in an array until it finds the index of an element whose value is <FONT FACE="courier, couriernew, monospaced size">theValue</FONT>:</zparagraph>
</FONT>
<P>
<A NAME="1015015"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>for (i = 0; i &lt; a.length; i++) {<br>
&nbsp;&nbsp;&nbsp;if (a[i] = theValue)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br>
}
</zcodeline>
</FONT>
<P><P>
<BR>
<A NAME="1008402"> </A>
<A NAME="continue Statement"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="4">
<zhead2>continue Statement</zhead2>
</FONT>
<BR>
<BR>



<A NAME="1015074"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The <FONT FACE="courier, couriernew, monospaced size">continue</FONT> statement can be used to restart a <FONT FACE="courier, couriernew, monospaced size">while</FONT>, <FONT FACE="courier, couriernew, monospaced size">do-while</FONT>, <FONT FACE="courier, couriernew, monospaced size">for</FONT>, or <FONT FACE="courier, couriernew, monospaced size">label</FONT> statement.</zparagraph>
</FONT>
<P>
<ul>
<A NAME="1016510"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1>When you use <FONT FACE="courier, couriernew, monospaced size">continue</FONT> without a label, it terminates the current iteration of the innermost enclosing <FONT FACE="courier, couriernew, monospaced size">while</FONT>, <FONT FACE="courier, couriernew, monospaced size">do-while</FONT> or <FONT FACE="courier, couriernew, monospaced size">for</FONT> statement and continues execution of the loop with the next iteration. In contrast to the <FONT FACE="courier, couriernew, monospaced size">break</FONT> statement, <FONT FACE="courier, couriernew, monospaced size">continue</FONT> does not terminate the execution of the loop entirely. In a <FONT FACE="courier, couriernew, monospaced size">while</FONT> loop, it jumps back to the condition. In a <FONT FACE="courier, couriernew, monospaced size">for</FONT> loop, it jumps to the <FONT FACE="courier, couriernew, monospaced size">increment-expression</FONT>.</zsmartlist1>
</FONT>
<P><A NAME="1008405"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1>When you use <FONT FACE="courier, couriernew, monospaced size">continue</FONT> with a label, it applies to the looping statement identified with that label.</zsmartlist1>
</FONT>
<P></ul>

<A NAME="1015133"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The syntax of the <FONT FACE="courier, couriernew, monospaced size">continue</FONT> statement looks like the following:</zparagraph>
</FONT>
<P>
<A NAME="1015134"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>1. continue<br>
2. continue <I>label
</I></zcodeline>
</FONT>
<P>
<A NAME="1008410"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph><B>Example 1.</B> The following example shows a <FONT FACE="courier, couriernew, monospaced size">while</FONT> loop with a <FONT FACE="courier, couriernew, monospaced size">continue</FONT> statement that executes when the value of <FONT FACE="courier, couriernew, monospaced size">i</FONT> is three. Thus, <FONT FACE="courier, couriernew, monospaced size">n</FONT> takes on the values one, three, seven, and twelve.</zparagraph>
</FONT>
<P>
<A NAME="1008411"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>i = 0;<br>
n = 0;<br>
while (i &lt; 5) {<br>
&nbsp;&nbsp;&nbsp;i++;<br>
&nbsp;&nbsp;&nbsp;if (i == 3)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;continue;<br>
&nbsp;&nbsp;&nbsp;n += i;<br>
}
</zcodeline>
</FONT>
<P>
<A NAME="1008413"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph><B>Example 2.</B> A statement labeled <FONT FACE="courier, couriernew, monospaced size">checkiandj</FONT> contains a statement labeled <FONT FACE="courier, couriernew, monospaced size">checkj</FONT>. If <FONT FACE="courier, couriernew, monospaced size">continue</FONT> is encountered, the program terminates the current iteration of <FONT FACE="courier, couriernew, monospaced size">checkj</FONT> and begins the next iteration. Each time <FONT FACE="courier, couriernew, monospaced size">continue</FONT> is encountered, <FONT FACE="courier, couriernew, monospaced size">checkj</FONT> reiterates until its condition returns <FONT FACE="courier, couriernew, monospaced size">false</FONT>. When <FONT FACE="courier, couriernew, monospaced size">false</FONT> is returned, the remainder of the <FONT FACE="courier, couriernew, monospaced size">checkiandj</FONT> statement is completed, and <FONT FACE="courier, couriernew, monospaced size">checkiandj</FONT> reiterates until its condition returns <FONT FACE="courier, couriernew, monospaced size">false</FONT>. When <FONT FACE="courier, couriernew, monospaced size">false</FONT> is returned, the program continues at the statement following <FONT FACE="courier, couriernew, monospaced size">checkiandj</FONT>.</zparagraph>
</FONT>
<P>

<A NAME="1008414"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>If <FONT FACE="courier, couriernew, monospaced size">continue</FONT> had a label of <FONT FACE="courier, couriernew, monospaced size">checkiandj</FONT>, the program would continue at the top of the <FONT FACE="courier, couriernew, monospaced size">checkiandj</FONT> statement.</zparagraph>
</FONT>
<P>
<A NAME="1008415"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>checkiandj : <br>
&nbsp;&nbsp;&nbsp;while (i&lt;4) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.write(i + "&lt;BR&gt;"); <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i+=1; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;checkj : <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while (j&gt;4) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.write(j + "&lt;BR&gt;"); <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;j-=1; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ((j%2)==0)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;continue checkj;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.write(j + " is odd.&lt;BR&gt;");<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.write("i = " + i + "&lt;br&gt;");<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.write("j = " + j + "&lt;br&gt;");  <br>
&nbsp;&nbsp;&nbsp;}
</zcodeline>
</FONT>
<P>
<BR>
<BR>

<A NAME="1008417"> </A>
<A NAME="Object Manipulation Statements"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="4">
<zhead1>Object Manipulation Statements</zhead1>
<HR SIZE="2" NOSHADE>
</FONT>
<BR>


<A NAME="1008419"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>JavaScript uses the <FONT FACE="courier, couriernew, monospaced size">for...in</FONT> and <FONT FACE="courier, couriernew, monospaced size">with</FONT> statements to manipulate objects.</zparagraph>
</FONT>
<P>
<P>
<BR>
<A NAME="1008452"> </A>
<A NAME="for...in Statement"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="4">
<zhead2>for...in Statement</zhead2>
</FONT>
<BR>
<BR>



<A NAME="1008453"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The <FONT FACE="courier, couriernew, monospaced size">for...in</FONT> statement iterates a specified variable over all the properties of an object. For each distinct property, JavaScript executes the specified statements. A <FONT FACE="courier, couriernew, monospaced size">for...in</FONT> statement looks as follows:</zparagraph>
</FONT>
<P>
<A NAME="1008454"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>for (<I>variable</I> in <I>object</I>) {<br>
&nbsp;&nbsp;&nbsp;<I>statements</I> }
</zcodeline>
</FONT>
<P>
<A NAME="1008455"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph><B>Example.</B> The following function takes as its argument an object and the object's name. It then iterates over all the object's properties and returns a string that lists the property names and their values.</zparagraph>
</FONT>
<P>
<A NAME="1008456"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>function dump_props(obj, obj_name) {<br>
&nbsp;&nbsp;&nbsp;var result = "";<br>
&nbsp;&nbsp;&nbsp;for (var i in obj) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result += obj_name + "." + i + " = " + obj[i] + "&lt;BR&gt;"<br>
&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;&nbsp;result += "&lt;HR&gt;";<br>
&nbsp;&nbsp;&nbsp;return result;<br>
}
</zcodeline>
</FONT>
<P>
<A NAME="1008457"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>For an object <FONT FACE="courier, couriernew, monospaced size">car</FONT> with properties <FONT FACE="courier, couriernew, monospaced size">make</FONT> and <FONT FACE="courier, couriernew, monospaced size">model</FONT>, <FONT FACE="courier, couriernew, monospaced size">result</FONT> would be:</zparagraph>
</FONT>
<P>

<A NAME="1008458"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph><FONT FACE="courier, couriernew, monospaced size">car.make = Ford<br>car.model = Mustang</FONT></zparagraph>
</FONT>
<P>
<P>
<BR>
<A NAME="1008460"> </A>
<A NAME="with Statement"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="4">
<zhead2>with Statement</zhead2>
</FONT>
<BR>
<BR>



<A NAME="1008461"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The <FONT FACE="courier, couriernew, monospaced size">with</FONT> statement establishes the default object for a set of statements. JavaScript looks up any unqualified names within the set of statements to determine if the names are properties of the default object. If an unqualified name matches a property, then the property is used in the statement; otherwise, a local or global variable is used.</zparagraph>
</FONT>
<P>

<A NAME="1015235"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>A <FONT FACE="courier, couriernew, monospaced size">with</FONT> statement looks as follows:</zparagraph>
</FONT>
<P>
<A NAME="1008462"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>with (<I>object</I>){<br>
&nbsp;&nbsp;&nbsp;<I>statements<br>
</I>}
</zcodeline>
</FONT>
<P>
<A NAME="1008463"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph><B>Example.</B> The following <FONT FACE="courier, couriernew, monospaced size">with</FONT> statement specifies that the <FONT FACE="courier, couriernew, monospaced size">Math</FONT> object is the default object. The statements following the <FONT FACE="courier, couriernew, monospaced size">with</FONT> statement refer to the <FONT FACE="courier, couriernew, monospaced size">PI</FONT> property and the <FONT FACE="courier, couriernew, monospaced size">cos</FONT> and <FONT FACE="courier, couriernew, monospaced size">sin</FONT> methods, without specifying an object. JavaScript assumes the <FONT FACE="courier, couriernew, monospaced size">Math</FONT> object for these references.</zparagraph>
</FONT>
<P>
<A NAME="1008464"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>var a, x, y;;<br>
var r=10<br>
with (Math) {<br>
&nbsp;&nbsp;&nbsp;a = PI * r * r;<br>
&nbsp;&nbsp;&nbsp;x = r * cos(PI);<br>
&nbsp;&nbsp;&nbsp;y = r * sin(PI/2);<br>
}
</zcodeline>
</FONT>
<P>
<A NAME="1016553"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>Note: Using a <FONT FACE="courier, couriernew, monospaced size">with</FONT> statement can significantly slow down your program.</zparagraph>
</FONT>
<P>

<BR>
<BR>

<A NAME="1008468"> </A>
<A NAME="Comments"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="4">
<zhead1>Comments</zhead1>
<HR SIZE="2" NOSHADE>
</FONT>
<BR>


<A NAME="1008469"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>Comments are author notations that explain what a script does. Comments are ignored by the interpreter. JavaScript supports Java and C++-style comments:</zparagraph>
</FONT>
<P>
<ul>
<A NAME="1008471"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1>Comments on a single line are preceded by a double-slash (//).</zsmartlist1>
</FONT>
<P><A NAME="1008474"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1>Comments that span multiple lines are preceded by /* and followed by */:</zsmartlist1>
</FONT>
<P></ul>

<A NAME="1008475"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph><B>Example.</B> The following example shows two comments:</zparagraph>
</FONT>
<P>
<A NAME="1008476"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>// This is a single-line comment.
</zcodeline>
</FONT>
<P><A NAME="1008477"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>/* This is a multiple-line comment. It can be of any length, and<br>
you can put whatever you want here. */
</zcodeline>
</FONT>
<P>
<BR>
<BR>

<A NAME="1011537"> </A>
<A NAME="Exception Handling Statements"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="4">
<zhead1>Exception Handling Statements</zhead1>
<HR SIZE="2" NOSHADE>
</FONT>
<BR>


<A NAME="1011618"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>You can throw exceptions using the <FONT FACE="courier, couriernew, monospaced size">throw</FONT> statement and handle them using the <FONT FACE="courier, couriernew, monospaced size">try...catch</FONT> statements.</zparagraph>
</FONT>
<P>

<A NAME="1014426"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>You also use the <FONT FACE="courier, couriernew, monospaced size">try...catch</FONT> statement to handle Java exceptions. See <A HREF="lc.html#1033594"  >"Handling Java Exceptions in JavaScript" on page&nbsp;141</A> and <A HREF="lc.html#1032268"  >"Handling JavaScript Exceptions in Java" on page&nbsp;144</A> for information.</zparagraph>
</FONT>
<P>
<P>
<BR>
<A NAME="1014198"> </A>
<A NAME="The throw Statement"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="4">
<zhead2>The throw Statement</zhead2>
</FONT>
<BR>
<BR>



<A NAME="1014199"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>Use the <FONT FACE="courier, couriernew, monospaced size">throw</FONT> statement to throw an exception. When you throw an exception, you specify an expression containing the value of the exception:</zparagraph>
</FONT>
<P>
<A NAME="1014200"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>throw <I>expression
</I></zcodeline>
</FONT>
<P>
<A NAME="1014270"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The following code throws several exceptions.</zparagraph>
</FONT>
<P>
<A NAME="1014271"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>throw "Error2"; &nbsp;&nbsp;&nbsp;// generates an exception with a string value<br>
throw 42;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// generates an exception with the value 42<br>
throw true;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// generates an exception with the value true
</zcodeline>
</FONT>
<P>
<A NAME="1015276"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>You can specify an object when you throw an exception. You can then reference the object's properties in the <FONT FACE="courier, couriernew, monospaced size">catch</FONT> block. The following example creates an object <FONT FACE="courier, couriernew, monospaced size">myUserException</FONT> of type <FONT FACE="courier, couriernew, monospaced size">UserException</FONT> and uses it in a <FONT FACE="courier, couriernew, monospaced size">throw</FONT> statement.</zparagraph>
</FONT>
<P>
<A NAME="1015260"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>// Create an object type UserException<br>
function UserException (message) {<br>
&nbsp;&nbsp;&nbsp;this.message=message;<br>
&nbsp;&nbsp;&nbsp;this.name="UserException";<br>
}<br>
// Create an instance of the object type and throw it<br>
myUserException=new UserException("Value too high");<br>
throw myUserException;
</zcodeline>
</FONT>
<P><P>
<BR>
<A NAME="1012168"> </A>
<A NAME="The try...catch Statement"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="4">
<zhead2>The try...catch Statement</zhead2>
</FONT>
<BR>
<BR>



<A NAME="1012028"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The <FONT FACE="courier, couriernew, monospaced size">try...catch</FONT> statement marks a block of statements to try, and specifies one or more responses should an exception be thrown. If an exception is thrown, the <FONT FACE="courier, couriernew, monospaced size">try...catch</FONT> statement catches it.</zparagraph>
</FONT>
<P>

<A NAME="1015325"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The <FONT FACE="courier, couriernew, monospaced size">try...catch</FONT> statement consists of a <FONT FACE="courier, couriernew, monospaced size">try</FONT> block, which contains one or more statements, and zero or more <FONT FACE="courier, couriernew, monospaced size">catch</FONT> blocks, containing statements that specify what to do if an exception is thrown in the <FONT FACE="courier, couriernew, monospaced size">try</FONT> block. That is, you want the <FONT FACE="courier, couriernew, monospaced size">try</FONT> block to succeed, and if it does not succeed, you want control to pass to the <FONT FACE="courier, couriernew, monospaced size">catch</FONT> block. If any statement within the <FONT FACE="courier, couriernew, monospaced size">try</FONT> block (or in a function called from within the <FONT FACE="courier, couriernew, monospaced size">try</FONT> block) throws an exception, control immediately shifts to the <FONT FACE="courier, couriernew, monospaced size">catch</FONT> block. If no exception is thrown in the <FONT FACE="courier, couriernew, monospaced size">try</FONT> block succeed, the <FONT FACE="courier, couriernew, monospaced size">catch</FONT> block is skipped. The <FONT FACE="courier, couriernew, monospaced size">finally</FONT> block executes after the <FONT FACE="courier, couriernew, monospaced size">try</FONT> and <FONT FACE="courier, couriernew, monospaced size">catch</FONT> blocks execute but before the statements following the <FONT FACE="courier, couriernew, monospaced size">try...catch</FONT> statement.</zparagraph>
</FONT>
<P>

<A NAME="1015404"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The following example uses a <FONT FACE="courier, couriernew, monospaced size">try...catch</FONT> statement. The example calls a function that retrieves a month name from an array based on the value passed to the function. If the value does not correspond to a month number (1-12), an exception is thrown with the value "InvalidMonthNo" and the statements in the <FONT FACE="courier, couriernew, monospaced size">catch</FONT> block set the <FONT FACE="courier, couriernew, monospaced size">monthName</FONT> variable to "unknown".</zparagraph>
</FONT>
<P>
<A NAME="1015354"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>function getMonthName (mo) {<br>
&nbsp;&nbsp;&nbsp;mo=mo-1; // Adjust month number for array index (1=Jan, 12=Dec)<br>
&nbsp;&nbsp;&nbsp;var months=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul",<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Aug","Sep","Oct","Nov","Dec");<br>
&nbsp;&nbsp;&nbsp;if (months[mo] != null) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return months[mo]<br>
&nbsp;&nbsp;&nbsp;} else {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throw "InvalidMonthNo"<br>
&nbsp;&nbsp;&nbsp;}<br>
}
</zcodeline>
</FONT>
<P><A NAME="1015480"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>try {<br>
&nbsp;&nbsp;&nbsp;// statements to try<br>
&nbsp;&nbsp;&nbsp;monthName=getMonthName(myMonth) // function could throw exception<br>
}<br>
catch (e) {<br>
&nbsp;&nbsp;&nbsp;monthName="unknown"<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;logMyErrors(e) // pass exception object to error handler<br>
}
</zcodeline>
</FONT>
<P><BR>
<P>
<A NAME="1011888"> </A>
<A NAME="The catch Block"> </A>
<FONT FACE="Arial, Helvetica, sans-serif">
<B>
<zhead3>The catch Block</zhead3>
</B>
</FONT>
<BR>
<BR>

<A NAME="1011894"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>You can use a single <FONT FACE="courier, couriernew, monospaced size">catch</FONT> block to handle all exceptions that may be generated in the <FONT FACE="courier, couriernew, monospaced size">try</FONT> block, or you can use separate <FONT FACE="courier, couriernew, monospaced size">catch</FONT> blocks each of which handles a particular type of exception.</zparagraph>
</FONT>
<P>
<BR>
<P>
<A NAME="1016039"> </A>
<A NAME="Single catch Block"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>
<zhead4>Single catch Block</zhead4>
</B>
</FONT>
<BR>

<A NAME="1016040"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>Use a single <FONT FACE="courier, couriernew, monospaced size">try...catch</FONT> statement's <FONT FACE="courier, couriernew, monospaced size">catch</FONT> block (<I>recovery block</I>) to execute error-handling code for any exceptions thrown in the <FONT FACE="courier, couriernew, monospaced size">try</FONT> block.</zparagraph>
</FONT>
<P>

<A NAME="1013726"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>A single <FONT FACE="courier, couriernew, monospaced size">catch</FONT> block has the following syntax:</zparagraph>
</FONT>
<P>
<A NAME="1012989"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>catch (<I>catchID</I>) {<br>
&nbsp;&nbsp;&nbsp;<I>statements<br>
</I>}
</zcodeline>
</FONT>
<P>
<A NAME="1012761"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The <FONT FACE="courier, couriernew, monospaced size">catch</FONT> block specifies an identifier (<FONT FACE="courier, couriernew, monospaced size">catchID</FONT> in the preceding syntax) that holds the value specified by the <FONT FACE="courier, couriernew, monospaced size">throw</FONT> statement; you can use this identifier to get information about the exception that was thrown. JavaScript creates this identifier when the <FONT FACE="courier, couriernew, monospaced size">catch</FONT> block is entered; the identifier lasts only for the duration of the <FONT FACE="courier, couriernew, monospaced size">catch</FONT> block; after the <FONT FACE="courier, couriernew, monospaced size">catch</FONT> block finishes executing, the identifier is no longer available.</zparagraph>
</FONT>
<P>

<A NAME="1013878"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>For example, the following code throws an exception. When the exception occurs, control transfers to the <FONT FACE="courier, couriernew, monospaced size">catch</FONT> block.</zparagraph>
</FONT>
<P>
<A NAME="1016080"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>try {<br>
&nbsp;&nbsp;&nbsp;throw "myException" // generates an exception<br>
}<br>
catch (e) {<br>
&nbsp;&nbsp;&nbsp;// statements to handle any exceptions<br>
&nbsp;&nbsp;&nbsp;logMyErrors(e) // pass exception object to error handler<br>
}
</zcodeline>
</FONT>
<P><BR>
<P>
<A NAME="1016086"> </A>
<A NAME="Multiple catch Blocks"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>
<zhead4>Multiple catch Blocks</zhead4>
</B>
</FONT>
<BR>

<A NAME="1016082"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>A single <FONT FACE="courier, couriernew, monospaced size">try</FONT> statement can contain multiple conditional catch blocks, each of which handles a specific type of exception. In this case, the appropriate conditional <FONT FACE="courier, couriernew, monospaced size">catch</FONT> block is entered only when the exception specified for that block is thrown. You can also include an optional catch-all <FONT FACE="courier, couriernew, monospaced size">catch</FONT> block for all unspecified exceptions as the final <FONT FACE="courier, couriernew, monospaced size">catch</FONT> block in the statement.</zparagraph>
</FONT>
<P>

<A NAME="1016123"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>For example, the following function invokes three other functions (declared elsewhere), which validate its arguments. If a validation function determines that the component that it is checking is invalid, it returns 0, causing the caller to throw a particular exception. </zparagraph>
</FONT>
<P>
<A NAME="1016130"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>function getCustInfo(name, id, email)<br>
{<br>
&nbsp;&nbsp;&nbsp;var n, i, e;
</zcodeline>
</FONT>
<P><A NAME="1016152"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>&nbsp;&nbsp;&nbsp;if (!validate_name(name))<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throw "InvalidNameException"<br>
&nbsp;&nbsp;&nbsp;else<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;n = name;<br>
&nbsp;&nbsp;&nbsp;if (!validate_id(id))<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throw "InvalidIdException"<br>
&nbsp;&nbsp;&nbsp;else<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i = id;<br>
&nbsp;&nbsp;&nbsp;if (!validate_email(email))<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throw "InvalidEmailException"<br>
&nbsp;&nbsp;&nbsp;else<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e = email;<br>
&nbsp;&nbsp;&nbsp;cust = (n + " " + i + " " + e);<br>
&nbsp;&nbsp;&nbsp;return (cust);<br>
}
</zcodeline>
</FONT>
<P>
<A NAME="1016157"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The conditional catch blocks route control to the appropriate exception handler.</zparagraph>
</FONT>
<P>
<A NAME="1016177"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>try {
</zcodeline>
</FONT>
<P><A NAME="1016570"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>// function could throw three exceptions<br>
&nbsp;&nbsp;&nbsp;getCustInfo("Lee", 1234, "lee@netscape.com") <br>
} 
</zcodeline>
</FONT>
<P><A NAME="1016571"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>catch (e if e == "InvalidNameException") {<br>
// call handler for invalid names<br>
bad_name_handler(e)<br>
}
</zcodeline>
</FONT>
<P><A NAME="1016184"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>catch (e if e == "InvalidIdException") {<br>
// call handler for invalid ids<br>
bad_id_handler(e)<br>
}
</zcodeline>
</FONT>
<P><A NAME="1016188"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>catch (e if e == "InvalidEmailException") {<br>
// call handler for invalid email addresses<br>
bad_email_handler(e)<br>
}
</zcodeline>
</FONT>
<P><A NAME="1016192"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>catch (e){<br>
// don't know what to do, but log it<br>
logError(e)<br>
}
</zcodeline>
</FONT>
<P><BR>
<P>
<A NAME="1016089"> </A>
<A NAME="The finally Block"> </A>
<FONT FACE="Arial, Helvetica, sans-serif">
<B>
<zhead3>The finally Block</zhead3>
</B>
</FONT>
<BR>
<BR>

<A NAME="1013096"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The <FONT FACE="courier, couriernew, monospaced size">finally</FONT> block contains statements to execute after the <FONT FACE="courier, couriernew, monospaced size">try</FONT> and <FONT FACE="courier, couriernew, monospaced size">catch</FONT> blocks execute but before the statements following the <FONT FACE="courier, couriernew, monospaced size">try...catch</FONT> statement. The <FONT FACE="courier, couriernew, monospaced size">finally</FONT> block executes whether or not an exception is thrown. If an exception is thrown, the statements in the <FONT FACE="courier, couriernew, monospaced size">finally</FONT> block execute even if no <FONT FACE="courier, couriernew, monospaced size">catch</FONT> block handles the exception.</zparagraph>
</FONT>
<P>

<A NAME="1015345"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>You can use the <FONT FACE="courier, couriernew, monospaced size">finally</FONT> block to make your script fail gracefully when an exception occurs; for example, you may need to release a resource that your script has tied up. The following example opens a file and then executes statements that use the file (server-side JavaScript allows you to access files). If an exception is thrown while the file is open, the <FONT FACE="courier, couriernew, monospaced size">finally</FONT> block closes the file before the script fails.</zparagraph>
</FONT>
<P>
<A NAME="1016578"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>openMyFile();<br>
try {<br>
&nbsp;&nbsp;&nbsp;writeMyFile(theData)<br>
}<br>
finally {<br>
&nbsp;&nbsp;&nbsp;closeMyFile() // always close the resource<br>
}
</zcodeline>
</FONT>
<P><BR>
<P>
<A NAME="1012802"> </A>
<A NAME="Nesting try...catch Statements"> </A>
<FONT FACE="Arial, Helvetica, sans-serif">
<B>
<zhead3>Nesting try...catch Statements</zhead3>
</B>
</FONT>
<BR>
<BR>

<A NAME="1012803"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>You can nest one or more <FONT FACE="courier, couriernew, monospaced size">try...catch</FONT> statements. If an inner <FONT FACE="courier, couriernew, monospaced size">try...catch</FONT> statement does not have a <FONT FACE="courier, couriernew, monospaced size">catch</FONT> block, the enclosing <FONT FACE="courier, couriernew, monospaced size">try...catch</FONT> statement's <FONT FACE="courier, couriernew, monospaced size">catch</FONT> block is checked for a match.</zparagraph>
</FONT>
<P>



   </BLOCKQUOTE>
</BOOKCONTENT>

<FOOTERCONTENT>
   <BLOCKQUOTE>
 <BR>
            <b><a href="regexp.html">
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#993300">Previous</a></FONT>&nbsp;&nbsp;&nbsp;&nbsp;</b>
<a href="contents.html">
<b><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#993300">Contents</a></FONT></b>&nbsp;&nbsp;&nbsp;&nbsp;
<a href="ix.html"><b><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#993300">Index</a></FONT></b>&nbsp;&nbsp;&nbsp;&nbsp;
<a href="fcns.html">
<b>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#993300">
Next
</a>
</FONT>
</b>&nbsp;&nbsp;&nbsp;&nbsp;
        <HR NOSHADE SIZE="1">


   <font face="Arial, Helvetica, sans-serif" SIZE="1">

Copyright &#169; 2000 <a href="http://www.netscape.com">Netscape Communications Corp.</a> All rights reserved.</FONT>
   </BLOCKQUOTE>
   <FONT FACE="Arial, Helvetica, sans-serif" SIZE="1">
   <P ALIGN="RIGHT">Last Updated <B>September 28, 2000</B>
   </FONT>
   <BR>

</FOOTERCONTENT>

</MAINCONTENT>

</BODY>


</HTML>